<template>
    <el-row class="paraMan">
        <el-row type="flex" style="height: 40px;margin-bottom: 14px;position: relative">
<!--            <el-input placeholder="请输入内容" style="width: 300px;margin-right: 20px;"></el-input>-->
<!--            <el-button type="primary" style="width: 100px;">搜索</el-button>-->
<!--            <el-button type="primary" style="width: 100px;height: 40px;position: absolute;right: 120px;">导出</el-button>-->
            <el-button type="primary" @click="addFirstPara" style="width: 100px;position: absolute;right: 0;">新增参数
            </el-button>
        </el-row>
        <el-table
                :data="paraData"
                style="width: 100%;font-size: 16px;"
                height="730"
                max-height="730"
                row-key="uuid"
                :header-cell-style="{background:'#e5ecf1',fontWeight: 'bold',textAlign: 'center'}"
                border
                highlight-current-row
                :default-expand-all="false"
                :tree-props="{children: 'subParas', hasChildren: 'hasChildren'}">
            <el-table-column prop="name" label="名称" min-width="260"></el-table-column>
            <el-table-column prop="code" label="代码" min-width="230"></el-table-column>
            <el-table-column prop="val" label="值" min-width="300">
                <template slot-scope="scope">
                    <el-row class="textHidden">
                        {{scope.row.val}}
                    </el-row>
                </template>
            </el-table-column>
            <el-table-column label="操作" width="100">
                <template slot-scope="scope">
                    <el-button type="text" size="mini" @click="addPara(scope.row)"
                               style="font-size: 16px;line-height: 10px;">新增
                    </el-button>
                    <el-button type="text" size="mini" @click="editPara(scope.row)"
                               style="font-size: 16px;line-height: 10px;">修改
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        <transition name="el-fade-in">
            <floatingBox v-show="editBoxShow">
                <addFirstPara v-if="addFirstShow" slot="edit" @editState="editState"></addFirstPara>
                <addPara v-if="addShow" slot="edit" :paraUuid="uuid" @editState="editState"></addPara>
                <editPara v-if="editShow" slot="edit" :paraUuid="uuid" @editState="editState"></editPara>
            </floatingBox>
        </transition>
    </el-row>
</template>

<script>
    import floatingBox from "../../public/floatingBox.vue";
    import addFirstPara from "./addFirstPara.vue";
    import editPara from "./editPara.vue";
    import addPara from "./addPara.vue";

    export default {
        name: "paraMan",
        components: {floatingBox, addFirstPara, addPara, editPara},
        data() {
            return {
                editBoxShow: false,
                addFirstShow: false,
                addShow: false,
                editShow: false,
                defaultExpandAll: false,
                paraEdit: false,
                paraData: [],
                uuid: '',
                paraProps: {
                    children: 'subParas',
                    label: 'name'
                }
            };
        },
        mounted() {
            this.queryPara();
        },
        methods: {
            editState(msg) {
                this.editBoxShow = msg;
                this.addFirstShow = msg;
                this.editShow = msg;
                this.addShow = msg;
                this.queryPara();
            },
            addFirstPara() {
                this.editBoxShow = true;
                this.addFirstShow = true;
            },
            addPara(val) {
                this.uuid = val.uuid;
                this.editBoxShow = true;
                this.addShow = true;
                this.paraEdit = true;
            },
            editPara(val) {
                this.uuid = val.uuid;
                this.editBoxShow = true;
                this.editShow = true;
                this.paraEdit = true;
            },
            paraChg(val) {
                if (this.paraEdit) {
                    this.uuid = val.uuid;
                }
            },
            //查询总量参数
            queryPara() {
                this.axios.request({
                    method: "get",
                    url: "./kwp/kdi/para/search/findAllTree",
                    params: {}
                }).then(response => {
                    this.paraData = response.data;
                }).catch(error => {
                    console.log(error);
                });
            },
        }
    }
</script>

<style scoped>
    .paraMan {
        margin-right: 30px;
    }

    .paraTreeBtn {
        font-size: 14px;
        cursor: pointer;
        color: #66b1ff;
    }

    .paraTreeBtn:hover {
        color: #8AC4FF;
    }
</style>